//用户选择
function selectSH(id) {
	var te = $("#SH").attr("btnType");
	if(te == "隐藏") {
		$("#SH").attr("btnType", "显示");
		$("#selectBox").fadeIn(600, function() {
			$("#selectBox").css("display", "block")
		})
	}
	if(te == "显示") {
		$("#SH").attr("btnType", "隐藏");
		$("#selectBox").fadeOut(600, function() {
			$("#selectBox").css("display", "none")
		})
	}

}

//设置session参数
function setSessionfunc(typeid,zid,tankuang,danweiID){
	// 设置当前用户的session值
    // typeid 系统分类id (比如对应前端八大类), zid 当前用户的站点id
	var url="/bigscrenn/setUserSession?typeid="+typeid+"&zid="+zid+"&cid="+tankuang+"&cid1="+danweiID;
    console.log(url,"session参数");
	$.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     async: false,				   
	     success: function(data){
              console.log(data,'参数');         
	     }
    		
    });	
};
zhanDianList();
var vm;
function zhanDianList(){
	//var sy_userid = localStorage.getItem("homeid");//获取登录用户ID
	//var sy_uniId = localStorage.getItem("unitid");//获取单位ID
	//alert("sy_userid=="+sy_userid+"sy_uniId==="+sy_uniId);
	vm = new Vue({
		el:"#app",
		data:{
			tabs:[],//电气图tabs
			urlStr:"",//电气图地址
			picName:'',//电气图名
			kehu:[],//站点
			zid :"",   //站点id
			danweiID:'',//单位id
			danweiName:'',//上页选中来的单位名称
			unitName:'',//登录的单位名称
			zName:'',   //站点名称
			CID:'',
			userid:'',
			unitID:'',
			userType:'',
			danweiID:'',
			danweiName:'',
		},
		mounted:function(){
			//this.getData();
			this.getSessionFunc();
			//this.getUnitIData();
		},
		methods:{
			getSessionFunc:function(){
				//sessionS
				var vs = this;
				var userid,unitID,userType,danweiID,danweiName,CID;
				var url="/bigscrenn/getUserSession";
			     $.ajax({
				     cache: true,
				     type: "POST",
				     url:url,
				     data:"",
				     async: false,				   
				     success: function(data){
				    	 console.log("session数据：",data);
				    	 //js解析json串
			     	     var obj = JSON.parse(data);
			             if (obj.session.length>0){
			                   /*alert(obj.session[0].UserID);//用户id
			                   alert(obj.session[0].Name);//用户名称
			                   alert(obj.session[0].UnitID);//用户单位id
			                   alert(obj.session[0].UserAuthority);//用户权限 2 所有单位 3 本单位
			                   alert(obj.session[0].typeid);//系统分类id (比如对应前端八大类)
			                   alert(obj.session[0].zid);//当前用户的站点id*/
			            	   vs.userid = obj.session[0].UserID;
			            	   vs.unitID = obj.session[0].UnitID;
			            	   
			            	   vs.CID = obj.session[0].zid;
			            	   //alert("vs.CID = "+vs.CID + "vs.userid = "+vs.userid);  
			            	   
			            	   vs.danweiID = (obj.session[0].cid1).split(",")[0];  //单位id方法
			            	   vs.danweiName = (obj.session[0].cid1).split(",")[1];//上页选中来的单位名称
			 	  			   
			 	  			   //vs.zid = obj.session[0].zid;
			 	  			   vs.zid = (obj.session[0].zid).split(",")[0];  //站点id
			 	  			   vs.zName = (obj.session[0].zid).split(",")[1];//上页选中来的站点名称
			 	  			   console.log("我是三级站点id 和名称 ="+vs.zid + "名称" +vs.zName+" 单位id = "+vs.danweiID+"  单位名称 = "+vs.danweiName);
			            	   
			 	  			   zhandianid = vs.zid;
			 	  			   onlineFunc();
			 	  			   
			 	  			   $("#unitTitle span").text(vs.zName);//进来默认标题
			                   //setSessionfunc('',vs.zid+','+vs.zName,'',(vs.danweiID+','+vs.danweiName));     // session存站点（第二个参）
			 	  			   
			            	 }
			             	if(vs.danweiID==''||vs.danweiID==null||vs.danweiID==undefined){
			             		vs.danweiID = vs.unitID;
			             	}
			                //alert("userid="+vs.userid+"unitID="+vs.unitID+"danweiID="+vs.danweiID+"CID="+CID);
			             	
			                console.info("--四遥列表页面-unitID-" + vs.userid);
			            	//alert("--四遥列表页面站点id--" + CID);
			                setTimeout(yoace,300,vs.userid,vs.zid);
			            	
			                setTimeout(yoakong,500,vs.userid,vs.zid);
			                
			                setTimeout(yoatiao,300,vs.userid,vs.zid);
			                
			                setTimeout(yoaxin,500,vs.userid,vs.zid);
			            	
			            	vs.getUnitIData(vs.userid,vs.danweiID);
				     }
			     });
				//sessionE
			},
			//站点
			getUnitIData:function(sy_userid,sy_uniId){
				var unitData = this;
				//userid用户id,unitid单位id,unitid为空时表示调用多个单位的站点信息
			    var url="/bigscrenn/getSiteList?userid="+sy_userid+"&unitid="+sy_uniId;
			    //alert("--unitid单位url====:" + url);
			     $.ajax({
				     cache: true,
				     type: "POST",
				     url:url,
				     data:"",
				     async: false,				   
				     success: function(data){
                       //alert("站点列表="+data);
                       //js解析json串
                       var obj = JSON.parse(data);
                       //alert(obj.total);//记录数
                       unitData.kehu = obj.rows;//分类后的站点（用户）
                       unitData.$nextTick(function() {
                    	   var arrr = $(".zhanDian");
                    	   var firstACID = $(".zhanDian:first()").attr("cid");
                    	   localStorage.setItem("fourPageCID", firstACID); //当没有点击过的cid，存在就存第一个
                    	   for (var n=0;n<arrr.length;n++){
                    		   arrr[n].index = n;
                    		   arrr[n].onclick = function(){
                    			   for (var i=0;i<obj.rows.length;i++){
                   					}
                    			   localStorage.setItem("fourPageCID", $(this).attr("cid"));
                    			   setSessionfunc('',$(this).attr("cid")+','+$(this).text(),'',(unitData.danweiID+','+unitData.danweiName));     // session存站点（第二个参）
                    			   //alert($(this).attr('cid'));
                    			   window.location.href = "specificUser.html";    //返回用户首页
	                        	   selectSH();//关闭用户(站点)列表
                    		   }
                    		   
                    	   }
                       });
				     }
			     });
			}
		}
	})
}
//用户选择结束



function yoace(userid,CID)
{
	//遥测ajax部分
	//参数userid用户id,unitid站点id
	var ycArr = [];
    var url="/bigscrenn/getYcList?userid="+userid+"&unitid="+CID;
    //alert("四遥列表页面 url=="+url);
    console.log("遥测url="+url);
     $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     async: false,				   
	     success: function(data){
               //alert(data);
               //js解析json串
               var obj = JSON.parse(data);
               //alert(obj.total);//记录数
               for (var i=0;i<obj.rows.length;i++){
                     //alert(obj.rows[i].YCNAME);//名称
                    // alert(obj.rows[i].VALUEA);//值
                     //alert(obj.rows[i].CONVERSION);//单位
            	   ycArr.push({"bianhao": i+1,"name": obj.rows[i].YCNAME,"value":obj.rows[i].VALUEA,"danwei": obj.rows[i].CONVERSION,"cDate":obj.rows[i].CDATE});
            	   
               }
               //alert("ycArr==="+ycArr); 
               localStorage.setItem("ycArr",JSON.stringify(ycArr));//存储目的点击详情弹框获取展示
               
             //遥测表格部分
               $('#yoaceID').bootstrapTable({
	          	    data:ycArr,
	          		//列数
	          		columns: [{
	          				field: 'bianhao',
	          				title: '编号',
	          				width: '100px'
	          			},
	          			{
	          				field: 'name',
	          				title: '名称',
	          			},
	          			{
	          				field: 'value',
	          				title: '值',
	          				width: '150px'
	          			},
	          			{
	          				field: 'danwei',
	          				title: '单位',
	          				width: '100px'
	          			},
	          			{
		       				field: 'cDate',
		       				title: '更新时间',
		       				width:200,
		       			}
	
	          		]
	          });
	          //遥测表结束
	     }
     });
     
     
}


//遥信开始
//得到遥信列表

function yoaxin(userid,CID){
	var yxArr = [];
    //参数userid用户id,unitid站点id
    var url="/bigscrenn/getYxList?userid="+userid+"&unitid="+CID;
    console.log("要信url="+url);
     $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     async: false,				   
	     success: function(data){
           //alert(data);
           //js解析json串
           var obj = JSON.parse(data);
           //alert(obj.total);//记录数
           for (var i=0;i<obj.rows.length;i++)
           {
                 //alert(obj.rows[i].YXNAME);//名称
                 //alert(obj.rows[i].VALUEA);//状态
        	     yxArr.push({"bianhao": i+1,"name": obj.rows[i].YXNAME,"stay":obj.rows[i].VALUEA,"cDate":obj.rows[i].CDATE});
           }
            //alert("----"+JSON.stringify(yxArr)); 
           localStorage.setItem("yxArr",JSON.stringify(yxArr));//存储目的点击详情弹框获取展示
           $('#yoaxinID').bootstrapTable({
	       		data:yxArr, 
	       		columns: [{
	       				field: 'bianhao',
	       				title: '编号',
	       				width: '100px'
	       			},
	       			{
	       				field: 'name',
	       				title: '名称',
	       				width:500,
	       			},
	       			{
	       				field: 'stay',
	       				title: '状态',
	       				width: '100px'
	       			},
	       			{
	       				field: 'cDate',
	       				title: '更新时间',
	       				width:200,
	       			}
	
	       		]
       	   });
	     }
     });
     
}
//遥信表结束

//遥调开始
//得到遥调列表

function yoatiao(userid,CID){
	var ytArr = [];
    //参数userid用户id,unitid站点id
    var url="/bigscrenn/getYtList?userid="+userid+"&unitid="+CID;
    console.log("要调url="+url);
     $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     async: false,				   
	     success: function(data){
               //alert(data);
               //js解析json串
               var obj = JSON.parse(data);
               //alert(obj.total);//记录数
               for (var i=0;i<obj.rows.length;i++)
               {
                     //alert(obj.rows[i].YTNAME);//名称
                     //alert(obj.rows[i].CMAX);//最大值
                     //alert(obj.rows[i].CMIN);//最小值
                     //alert(obj.rows[i].CONVERSION);//单位
            	   	 ytArr.push({"bianhao": i+1,"name": obj.rows[i].YTNAME,"value":obj.rows[i].CMAX,"newValue": obj.rows[i].CMIN,"danwei": obj.rows[i].CONVERSION});
            	   	
               }
               //alert("--ytArr--"+JSON.stringify(ytArr)); 
               localStorage.setItem("ytArr",JSON.stringify(ytArr));//存储目的点击详情弹框获取展示
               
               $('#yoatiaoID').bootstrapTable({
	           		data: ytArr,
	           		columns: [{
	           				field: 'bianhao',
	           				title: '编号',
	           				width: '100px'
	           			},
	           			{
	           				field: 'name',
	           				title: '名称',
	           			},
	           			{
	           				field: 'value',
	           				title: '值',
	           				width: '150px'
	           			},
	           			{
	           				field: 'newValue',
	           				title: '新值',
	           				width: '150px'
	           			},
	           			{
	           				field: 'danwei',
	           				title: '单位',
	           				width: '100px'
	           			},
	           			/*{
	           				field: 'caozuo',
	           				title: '操作',
	           			}*/
	
	           		]
	          });
	     }
     });
     
     
}


//遥调表结束
//遥控开始
//得到遥控列表

function yoakong(userid,CID){
	var ykArr = [];
    //参数userid用户id,unitid站点id
    var url="/bigscrenn/getYkList?userid="+userid+"&unitid="+CID;
    console.log("遥控url="+url);
     $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     async: false,				   
	     success: function(data){
	           //alert("遥控data="+data);
	           //js解析json串
	           if(data&&data!=''){
	        	   var obj = JSON.parse(data);
		           //alert(obj.total);//记录数
		           for (var i=0;i<obj.rows.length;i++)
		           {
		                 //alert(obj.rows[i].YKNAME);//名称
		                 //alert(obj.rows[i].DESCRIBEDB);//描述
		        	   ykArr.push({"bianhao": i+1,"name": obj.rows[i].YKNAME,"describ":obj.rows[i].DESCRIBEDB,"cid":obj.rows[i].CID});
		        	   
		           } 
		           //alert("ykArr="+ykArr);
		           localStorage.setItem("ykArr",JSON.stringify(ykArr));//存储目的点击详情弹框获取展示
		           
		           $('#yoakongID').bootstrapTable({
			       		data: ykArr,
			       		columns: [{
			       				field: 'bianhao',
			       				title: '编号',
			       				width: '100px'
			       			},
			       			{
			       				field: 'name',
			       				title: '名称',
			       			},
			       			{
			       				field: 'describ',
			       				title: '描述',
			       			},
			       			{
			       				field: 'cid',
			       				title: 'id',
			       				visible:false
			       			}
	
			       		],
			       		
			       		onClickRow:function (row,$element) {
	 						var trIndex = $element.data('index'); //获取点击行号
	 						//alert(trIndex);
	 						$(".tipmsg").hide();
	 						yaokongYanzhengFunc();
	 						console.log(row.cid," 遥控 获取点击行号 ");
	 						//询问框
	 						row_cid = row.cid

	 						/*layer.confirm('您确定要执行吗？', {
	 						  btn: ['确定','取消'] //按钮
	 						}, function(){
	 							zhixingYK_test(row.cid);
	 						    layer.msg('执行成功！', {icon: 1});
	 						}, function(){
	 						  layer.msg('您将要取消执行！', {
	 						    time: 20000, //20s后自动关闭
	 						    btn: ['是', '否']
	 						  });
	 						});*/
	 						$(".layui-layer-title").text("发送遥控信息");
	 						$(".layui-layer-content").css("textAlign",'center')
			    		}
			       });
		           
	           }
                           
	     }
     });
}
//执行遥控指令
function zhixingYK_test(cid){
	//alert(cid);
    //参数cid遥控的cid值
    var url="/Gateway/sdocmd?cid="+cid;
     $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     async: false,				   
	     success: function(data){
	    	 
              //alert("遥控指令已发送！");
                           
	     }
     });
     
}
//遥控表结束
//点击详情开始
function openLayerFunc(id){
	var yaoce = $("#yaoce").attr("id");           //获取遥测ID
	var yaoxin = $("#yaoxin").attr("id");         //获取遥信ID
	var yaotiao = $("#yaotiao").attr("id");       //获取遥调ID
	var yaokong = $("#yaokong").attr("id");       //获取遥控ID
	//alert("yaoce=:"+yaoce);
	
	if(id==yaoce){
		id=yaoce;
	}
	if(id==yaoxin){
		id=yaoxin;
	}
	if(id==yaotiao){
		id=yaotiao;
	}
	if(id==yaokong){
		id=yaokong;
	}
	//alert("id="+id);
	setSessionfunc('','',id);//点击详情进入弹框要用到
	
	var area = [];
	var success;
	var ycArrL = JSON.parse(localStorage.getItem("ycArr"));//获取遥测数据条数
	var ytArrL = JSON.parse(localStorage.getItem("ytArr"));//获取遥测数据条数
	var yxArrL = JSON.parse(localStorage.getItem("yxArr"));//获取遥测数据条数
	var ykArrL = JSON.parse(localStorage.getItem("ykArr"));//获取遥测数据条数
	//alert("ykArrL=="+(ykArrL*30).toString());
	var title = '';
	if(ycArrL && ycArrL != 'null' && ycArrL != 'undefined' && id == yaoce){//当点击推送消息的详情时的操作
		console.log("is遥测ID")
		ifFunc('遥测',yaoce,ycArrL.length);
		console.log("ycArrL.length = "+ycArrL.length);
	}
	if(yxArrL && yxArrL != 'null' && yxArrL != 'undefined' && id == yaoxin){//当点击实时告警推送的详情时的操作
		console.log("is遥信ID")
		ifFunc('遥信',yaoxin,yxArrL.length);
		console.log("ycArrL.length = "+yxArrL.length);
		
	}if(ytArrL && ytArrL != 'null' && ytArrL != 'undefined' && id == yaotiao){
		console.log("is遥调ID");
		ifFunc("遥调",yaotiao,ytArrL.length);
		console.log("ycArrL.length = "+ytArrL.length);
		
	}if(ykArrL && ykArrL != 'null' && ykArrL != 'undefined' && id == yaokong){
		console.log("is遥控ID");
		ifFunc("遥控",yaokong,ykArrL.length);
		console.log("ycArrL.length = "+ykArrL.length);
	}
	function ifFunc(title,ID,arrL){
		var windowH = $(window).height();//浏览器时下窗口可视区域高度
		var tHeight = 0;
		
		var area = [];
		if(arrL && arrL>=3){//计算数据条数设置弹框高度
			tHeight = (arrL)*37+33;
			if(tHeight>windowH){
				tHeight=windowH-400;
			}
		}else{
			tHeight= 138;
		}
		//alert("tHeight="+(tHeight)+"str="+tHeight.toString());
		area = ['1000px',tHeight.toString()+'px'];
		
		layer.open({
			type: 2,
			title: false,
			//title:'实时告警详情',
			title:title,
			center:"center",
			closeBtn: 1,
			area: ['1010px', '500px'],
			resize:false,//是否允许拉伸
			//area: area,
			shadeClose: true,
			skin:"myskin",
			scrollbar:false,
			content: 'tanKuang.html',
			//content: '的发射点犯得上反对'
		});
		//layer 弹框标题、关闭x样式
		$('.myskin').css({
			'background':'#07256b'
		})
		$(".myskin a.layui-layer-ico").text('×').css({
			'color':'#fff',
			'fontSize':'2rem',
			'margin-top': '-15px',
			'background':'none'
		});
		
		$(".layui-layer-title").css({'color':'#fff',});
	}
	
}

//值班人员
//onlineFunc();
function onlineFunc(){
	//alert("zhandianid 3= "+zhandianid);
	// unitid 是站点ID
	// var url="/bigtongji/getRotaList?unitid=000000000001";
	var url="/bigtongji/getRotaList?unitid="+zhandianid;
	 $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     async: false,				   
	     success: function(data){
          // alert(data);
          console.log(data);
          var dataObj=eval("("+data+")");// 转换为json对象
          // alert(dataObj);
          // alert(dataObj);
          if(dataObj.rows.length>0){
      		 $("#onlineNotice").html('');
      		 for (var i = 0; i < dataObj.rows.length; i++) {
           		var cid= dataObj.rows[i].cid;
           		var name= dataObj.rows[i].rname;
           		var phone= dataObj.rows[i].phoneCode;
           		//alert(cid);
           		//alert("cid="+cid+"name="+name+"phone="+phone);
          		 $("#onlineNotice").append('<li><span>👨‍⚖️&nbsp;&nbsp;<span id="onlineName1">'+name+'</span>&nbsp;电话：</span><span>'+phone+'</span></li>');
           	  }
      	  }
      	 if(dataObj.rows.length==0){
      		$("#onlineNotice").html(''); 
      	 }
	     }
	 });

}
//值班人员结束

//返回上一级跳转逻辑处理
function bachFunc(){
	var urlsStr = localStorage.getItem("urls");
	var ss = JSON.parse(urlsStr);
    console.log(ss.yiji);
    if(ss.sanji != undefined && ss.sanji !=''){
    	//alert(ss.sanji);
	    location.href = './specificHome.html';
    	return;
    }if(ss.erji != undefined && ss.erji !=''){
    	//alert(ss.erji);
        location.href = './intlgMonitor.html';
        return;
    }if(ss.yiji != undefined && ss.yiji !=''){
    	//alert(ss.yiji);
	    location.href = './pro_Home.html';
		return;
    }else{
	    //alert(222)
    }
}

//遥控信息验证 方法
var phoneStr = "18786044261";
var interval;
var interval2;
function yaokongYanzhengFunc() {
	var yzm1 = $("#yanzhengma-input1").val();
	if(yzm1.length == 0) {
		$("#sure1").attr('disabled', true);
	}
	var yzm2 = $("#yanzhengma-input2").val();
	if(yzm2.length == 0) {
		$("#sure2").attr('disabled', true);
	}

	$('#my-prompt1').modal({
		closeViaDimmer: false, //点击遮罩不关闭modal
	});
}
function run1() {
	var s = document.getElementById('dd1');
	if(s.innerHTML == 0) {
		clearInterval(interval);
		$("#sure1").attr('disabled', true).css('color', 'initial');
		$("#tipmsg1").hide();
		$("#tipmsg1_1").show();
		$("#get-yzm1").attr('disabled', false);
		s.innerHTML = 120;
		return false;
	}
	s.innerHTML = s.innerHTML * 1 - 1;
}

function run2() {
	var ss = document.getElementById('dd2');
	if(ss.innerHTML == 0) {
		clearInterval(interval2);
		$("#sure2").attr('disabled', true).css('color', 'initial');
		$("#tipmsg2").hide();
		$("#tipmsg2_1").show();
		$("#get-yzm2").attr('disabled', false);
		ss.innerHTML = 120;
		return false;
	}
	ss.innerHTML = ss.innerHTML * 1 - 1;
}



//点击获取验证码按钮
$("#get-yzm1").on('click', function() {
	clearInterval(interval);
	interval = setInterval(run1, 1000);
	var id = $(this).attr("id");
	if(id == "get-yzm1") {
		$("#tipmsg1").show();
		$("#tipmsg1_1").hide();
		$("#sure1").attr('disabled', false).css('color', 'green');
		$("#get-yzm1").attr('disabled', true); //点击获取验证码后 自己禁止被点击
	}
	
	//得到发送短信的手机号1
	getHpone1();
	//alert("vm.userid = "+vm.userid);
	function getHpone1(){
	    //参数userid,用户id
	    //var url="/bigscrenn/getphonea?userid=0100000000000004";
		var url="/bigscrenn/getphonea?userid="+vm.userid;
	     $.ajax({
		     cache: true,
		     type: "POST",
		     url:url,
		     data:"",
		     async: false,				   
		     success: function(data){
                   //手机号
                   //alert(data);
                   phoneStr = data;            
		     }
	     });
	     
	}
	//发送短信1
	sendDX1()
	function sendDX1(){
	    //参数userid,用户id
	    //var url="/bigscrenn/sendphonea?userid=0100000000000004";
	    var url="/bigscrenn/sendphonea?userid="+vm.userid;
	     $.ajax({
		     cache: true,
		     type: "POST",
		     url:url,
		     data:"",
		     async: false,				   
		     success: function(data){
	               //返回值
	               //alert("发送短信1 = "+data);
		     }
	     });
	     
	}
	
	//点击获取验证码后 的提示信息
	if(phoneStr.length==11){
		var subStr_h = phoneStr.substr(0, 3); //手机前三位
		var subStr_f = phoneStr.substr(7, 4); //手机后四位
		//alert("phoneStr = "+phoneStr+"  subStr_h = "+subStr_h+" subStr_f = "+subStr_f);
		$(".phoneStr-h").text(subStr_h);
		$(".phoneStr-f").text(subStr_f);
	}if(phoneStr.length!=11){
		$('#my-prompt1').modal(close);
		layer.msg("手机有误，请联系管理员设置手机号！")
	}

	//$(".getYZM").attr('disabled', true); //点击获取验证码后 自己禁止被点击
	//调用120秒倒计时方法
})
$("#get-yzm2").on('click', function() {
	var id = $(this).attr("id");
	if(id == "get-yzm2") {
		$("#tipmsg2").show();
		phoneStr = "15011383218";

		clearInterval(interval2);
		interval2 = setInterval(run2, 1000);
		$("#tipmsg2").show();
		$("#tipmsg2_1").hide();
		$("#sure2").attr('disabled', false).css('color', 'green');
		$("#get-yzm2").attr('disabled', true); //点击获取验证码后 自己禁止被点击
	}
	
	//得到发送短信的手机号2
	getPhone2();
	function getPhone2(){
	    //参数userid,用户id
	    //var url="/bigscrenn/getphoneb?userid=0100000000000004";
	    var url="/bigscrenn/getphoneb?userid="+vm.userid;
	     $.ajax({
		     cache: true,
		     type: "POST",
		     url:url,
		     data:"",
		     async: false,				   
		     success: function(data){
	               //手机号
	               //alert("手机号2 = "+data);
	               phoneStr = data;
	                           
		     }
	     });
	     
	}
	
	//发送短信2
	sendDX2();
	function sendDX2(){
	    //参数userid,用户id
	    //var url="/bigscrenn/sendphoneb?userid=0100000000000004";
	    var url="/bigscrenn/sendphoneb?userid="+vm.userid;
	     $.ajax({
		     cache: true,
		     type: "POST",
		     url:url,
		     data:"",
		     async: false,				   
		     success: function(data){
                   //返回值
                   //alert("发送短信2 = "+data);
	                           
		     }
	     });
	     
	}
	
	//点击获取验证码后 的提示信息
	if(phoneStr.length==11){
		var subStr_h = phoneStr.substr(0, 3); //手机前三位
		var subStr_f = phoneStr.substr(7, 4); //手机后四位
		//alert("phoneStr = "+phoneStr+"  subStr_h = "+subStr_h+" subStr_f = "+subStr_f);
		$(".phoneStr-h1").text(subStr_h);
		$(".phoneStr-f1").text(subStr_f);
	}if(phoneStr.length!=11){
		$('#my-prompt2').modal(close);
		layer.msg("手机有误，请联系管理员设置手机号！")
	}

})

//点击关闭按钮
$("#closeBtn1").on('click', function() {
	$('#my-prompt1').modal(close);
})
$("#closeBtn2").on('click', function() {
	$('#my-prompt2').modal(close);
})
//点击确认按钮
$("#sure1").on('click', function() {
	clearInterval(run1);
	//alert($(this).attr("id"));
	/*$('#my-prompt1').modal(close);
	$('#my-prompt2').modal({
		closeViaDimmer: false, //点击遮罩不关闭modal
	});
	interval2 = setInterval(run2, 1000);*/
	
	//短信验证1
	yanzheng1();
	function yanzheng1(){
		var yonghuYZM = $("#yanzhengma-input1").val();
		//alert("yonghuYZM = "+yonghuYZM);
	    //参数userid:用户id，yzcode:验证码
	    //var url="/bigscrenn/lzphonea?userid=0100000000000004&yzcode=1234";
	    var url="/bigscrenn/lzphonea?userid="+vm.userid+"&yzcode="+yonghuYZM;
	     $.ajax({
		     cache: true,
		     type: "POST",
		     url:url,
		     data:"",
		     async: false,				   
		     success: function(data){
                   //返回值,1表示验证通过，0表示不通过。
                   //alert("短信验证1 = "+data);
                   if(data=="1"){
                	   layer.msg("用户验证成功");
                	   $('#my-prompt1').modal(close);
                	   setTimeout(function(){
                		   $('#my-prompt2').modal({
	                   		  closeViaDimmer: false, //点击遮罩不关闭modal
	                   	   });
                	   },3500)
                   }if(data=="0"){
                	   //layer.msg("用户验证失败")
                   }
		     }
	     });
	     
	}

})
$("#sure2").on('click', function() {
	var yonghuYZM2 = $("#yanzhengma-input2").val();
	//alert("yonghuYZM2 = "+yonghuYZM2 +" row_cid = "+row_cid);
	//短信验证2
	yanzheng2();
	function yanzheng2(){
	    //参数userid:用户id，yzcode:验证码
	    //var url="/bigscrenn/lzphoneb?userid=0100000000000004&yzcode=1234";
	    var url="/bigscrenn/lzphoneb?userid="+vm.userid+"&yzcode="+yonghuYZM2;
	     $.ajax({
		     cache: true,
		     type: "POST",
		     url:url,
		     data:"",
		     async: false,				   
		     success: function(data){
                   //返回值,1表示验证通过，0表示不通过。
                   //alert("短信验证2 = "+data);
                   if(data=='1'){
                	   layer.confirm('您确定要执行吗？', {
						  btn: ['确定','取消'] //按钮
						}, function(){
							zhixingYK_test(row_cid);
						    layer.msg('执行成功！', {icon: 1});
						    
						    setTimeout(function(){
						    	$('#my-prompt2').modal({
	 						   		closeViaDimmer: false, //点击遮罩不关闭modal
	 						   	});
						    },1500);
						}, function(){
						  //layer.msg('您将要取消执行！', {
						   // time: 20000, //20s后自动关闭
						   // btn: ['是', '否']
						  //});
						});
						$(".layui-layer-title").text("发送遥控信息");
						$(".layui-layer-content").css("textAlign",'center')
                   }if(data=='0'){
                	   layer.msg("领导验证失败，可能验证码有误！");
                   }
		     }
	     });
	     
	}

})
